/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package helper;

import java.awt.Component;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JTree;
import javax.swing.tree.DefaultTreeCellRenderer;

/**
 *
 * @author Tin Pham
 */
public class TreeCellRender extends DefaultTreeCellRenderer {

    ImageIcon rendererIcon;

    public void setRendererIcon(ImageIcon myIcon) {
        this.rendererIcon = myIcon;
    }

    public Component getTreeCellRendererComponent(JTree tree,
            Object value, boolean selected, boolean expanded,
            boolean leaf, int row, boolean hasFocus) {

        Component ret = super.getTreeCellRendererComponent(tree, value,
                selected, expanded, leaf, row, hasFocus);

        JLabel label = (JLabel) ret;

        label.setIcon(rendererIcon);

        return ret;
    }
}
